function test01() {
    var scale = function (val, stuff) {
        stuff.size *= val
    };
    var paint = function (val, stuff) {
        stuff.color = val
    };

    var scaleAndPaint = function (s, color, stuff) {
        scale(s, stuff);
        paint(color, stuff)
    };
    var box = {
        size: 10,
        color: 'green'
    };
    var box1 = {
        size: 5,
        color: 'green'
    };
//所有的盒子都要放大两倍
    scaleAndPaint(2, 'black', box);
    scaleAndPaint(2, 'black', box1);
    console.log(box, box1);//{ size: 20, color: 'black' } { size: 10, color: 'black' }
}

function test02() {
    var scale = function (val, stuff) {
        stuff.size *= val
    };
    var paint = function (val, stuff) {
        stuff.color = val
    };

    var scaleAndPaint = function (s, color, stuff) {
        scale(s, stuff);
        paint(color, stuff)
    };
    var box = {
        size: 10,
        color: 'green'
    };
    var box1 = {
        size: 5,
        color: 'green'
    };
    function operaBox(box) {
        scaleAndPaint(2, 'black', box);
    }

//所有的盒子都要放大两倍
    scaleAndPaint(2, 'black', box);
    scaleAndPaint(2, 'black', box1);
    console.log(box, box1);//{ size: 20, color: 'black' } { size: 10, color: 'black' }
}

//--------------------------------------------------------------------------------------------------------------------------------------------
test01();
